{extend name="index/public" /}

{block name="content"}
<form class="layui-form" action="" id="searchBox">
    <div class="layui-inline">
        <select name="year" id="year" lay-filter="year">
            <option value="">年份（3年总和）</option>
            <option value="2018" selected>2018年</option>
            <option value="2017">2017年</option>
            <option value="2016">2016年</option>
        </select>
    </div>
    <div class="layui-inline">
        <select name="plat" id="plat" lay-filter="plat">
            <option value="cps" selected>CPS</option>
            <option value="sdk">联运</option>
        </select>
    </div>
    <div class="layui-inline">
        <a href="javascript:;" class="layui-btn searchBtn my-btn my-btn-sm">搜索</a>
    </div>
</form>

<table id="tableBox" lay-filter="tableBox"></table>

{/block}

{block name="css"}
{/block}

{block name="js"}
<script>
    layui.use('table', function(){
        var table = layui.table
            ,$ = layui.$
            ,form = layui.form
            ,load = null
            ,active = {
                reload: function () {
                    var jsonObj = {
                        "year": $('#year').val()
                        ,"plat": $('#plat').val()
                    };

                    table.reload('tableId', {
                        page: {curr: 1}
                        ,where: jsonObj
                        ,height: 'full-100'
                    })
                },
            };

        //表格初始化
        table.render({
            elem: '#tableBox'
            ,height: 'full-100'
            ,url: '{:url("UserPay/index")}'
            ,where: {year:$('#year').val(), plat:$('#plat').val()}
            ,page: true
            ,limit:20
            ,limits:[20,40,60,80]
            ,loading:true
            ,id:'tableId'
            ,done: function () {
                layer.close(load);
                $('#layui-loading').hide();
            }
            ,cols: [[
                {field:'my_user_id', title: '用户ID', width: 110}
                ,{field:'my_user_name', title: '登录名称', width: 150}
                ,{field:'channel_id', title: '渠道类型', width: 150}
                ,{field:'total_price', title: '充值金额', width: 130}
            ]]
        });

        $('#searchBox .searchBtn').on('click', function(){
            load = layer.load();
            active['reload'].call(this);
            return false;
        });
    });
</script>
{/block}